<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="common/taglib.jsp" %>
<!DOCTYPE html>
<html>
<!-- Mirrored from www.zi-han.net/theme/hplus/clients.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:19:44 GMT -->
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>H+ 后台主题UI框架 - 客户管理</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">
    <jsp:include page="common/header.jsp"></jsp:include>
</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-sm-8">
                <div class="ibox">
                    <div class="ibox-content">
                        <h2>分类管理</h2>
                        <div class="input-group">
                            <input type="text" placeholder="查找分类" class="input form-control">
                            <span class="input-group-btn">
                                        <button type="button" class="btn btn btn-primary"> <i class="fa fa-search"></i> 搜索</button>
                                </span>
                        </div>
                        <div class="clients-list">
                            <div class="full-height-scroll">
                                <div class="table-responsive">
                                    <table class="table table-striped table-hover">
                                    <tr>
                                    	<th></th>
                                    	<th>分类名称</th>
                                    	<th>父分类名称</th>
                                    	<th>操作</th>
                                    </tr>
                                           <c:forEach items="${categoryList }" var="category">
                                            <tr>
                                                <td class="client-avatar"><img alt="image" src="${pageContext.request.contextPath }/view/${category.iconUrl }"> </td>
                                                <td>${category.name}</td>
                                                <td> ${category.parentName}</td>
                                                <td class="client-status">
                                                <a href="${pageContext.request.contextPath }/sys/cate/get/${category.id}" class="cate-upd"><span class="label label-primary">编辑</span></a>
                                                <a href="${pageContext.request.contextPath }/sys/cate/del/${category.id}" class="cate-del"><span class="label label-warning">删除</span></a>
                                                </td>
                                            </tr>
                                            </c:forEach>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-4">
                <div class="ibox ">

                    <div class="ibox-content">
                        <div class="tab-content">
                            <div id="contact-1" class="tab-pane active">
                                <div class="row m-b-lg">
                                    <div class="col-lg-4 text-center">
                                        <h2>添加分类</h2>
                                    </div>
                                    <div class="col-lg-8">
                                       <form action="" id="categoryForm">
                                       <div class="form-group">
                                        <label>分类名称</label>
                                        <input name="name" type="text" placeholder="请输入分类名称" class="form-control">
                                    </div>
                                    <div class="form-group">
                                        <label>父分类</label>
                                        <select class="form-control m-b" name="parentId">
                                        	<option value="0">请选择</option>
	                                        <c:forEach items="${parentCategoryList }" var="category">
	                                        	<option value="${category.id }">${category.name }</option>
	                                        </c:forEach>
	                                    </select>
                                    </div>
                                    <div class="form-group">
                                        <label>分类banner图</label>
                                        <img alt="" src="" id="bannerUrlFileImg">
                                        <input type="file" id="bannerUrlFile"  name="file" class="form-control">
                                        <input type="hidden" id="bannerUrl" name="bannerUrl" value="">
                                    </div>
                                    <div class="form-group">
                                        <label>分类图标</label>
                                        <img alt="" src="" id="iconUrlFileImg">
                                        <input type="file" id="iconUrlFile" name="file"  class="form-control">
                                        <input type="hidden" id="iconUrl" name="iconUrl" value="">
                                    </div>
                                        <button type="submit" class="btn btn-primary btn-sm btn-block">添加分类</button>
                                       </form>
                                    </div>
                                </div>
                                
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <jsp:include page="common/footer.jsp"></jsp:include>
<script
	src="${pageContext.request.contextPath }/static/js/ajaxfileupload.js"></script>
    <script>
        $(function(){$(".full-height-scroll").slimScroll({height:"100%"})});
    </script>
    <script type="text/javascript" >
    	$(function(){
    		
    		$("#bannerUrlFile").change(function(){
    			$.ajaxFileUpload({
    				url:"${pageContext.request.contextPath }/upload",
    				type:"POST",
    				fileElementId:"bannerUrlFile",
    				dataType:"json",
    				success:function(data){
    					//
    					$("#bannerUrl").val(data.fileId);
    					$("#bannerUrlFileImg").attr("src","${pageContext.request.contextPath }/view/" +data.fileId);
    				},
    				error:function(data){
    					console.error("upload file error");
    				}
    			});
    		})
    	
    		$("#iconUrlFile").change(function(){
    			$.ajaxFileUpload({
    				url:"${pageContext.request.contextPath }/upload",
    				type:"POST",
    				fileElementId:"iconUrlFile",
    				dataType:"json",
    				success:function(data){
    					//
    					$("#iconUrl").val(data.fileId);
    					$("#iconUrlFileImg").attr("src","${pageContext.request.contextPath }/view/" +data.fileId);
    				},
    				error:function(data){
    					console.error("upload file error");
    				}
    			});
    		})
    		
    		$("#categoryForm").submit(function(){
    			
    			$.ajax({
    				url:"${pageContext.request.contextPath }/sys/cate/add",
    				type:"POST",
    				data:$("#categoryForm").serialize(),
    				success:function(n){
    					if(n>0){
    						wxLayer.alert("添加成功",function(){
    							location.href = "${pageContext.request.contextPath }/sys/cate/list";
    						});
    					}else{
    							parent.layer.alert("添加失败");
    					}
    				},
    				error:function(){
    					
    				}
    			})
    			
    			return false;
    		})
    		$(".cate-upd").on("click",function(){
    			
    		})
    		$(".cate-del").on("click",function(){
    			var _this = this;//$(this)
    			wxLayer.confirm('确定要删除吗？',function(){
    			 $.ajax({
    				url:_this.href,
    				type:"POST",
    				success:function(n){
    					if(n>0){
    						wxLayer.alert("删除成功",function(){
    							location.href = "${pageContext.request.contextPath }/sys/cate/list";
    						});
    					}else{
    							parent.layer.alert("删除失败");
    					}
    				},
    				error:function(data){
    					
    				}
    			}) 
    			});
    			return false;
    		})
    	})
    	
    </script>
</body>


<!-- Mirrored from www.zi-han.net/theme/hplus/clients.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 20 Jan 2016 14:19:44 GMT -->
</html>
